package cn.kgc.jihe.Work02;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//员工管理
public class StaffManagement {
    public static List<Staff>staffList=new ArrayList<>();
    public static void add(Staff staff){
        staffList.add(staff);
    }
    public static List print(){return  staffList;};

    public static void remove(int index){
        staffList.remove(index);
        System.out.println("删除成功");
    }
    public static boolean judgy(Staff staff,Staff staffs){
        if (staff.getName().equals(staffs.getName()) && staff.getId() == staffs.getId()){
            return true;
        }else{
            return false;
        }
    }
    public static void main(String[] args) {

        boolean flag = true;
        do{
            Scanner input = new Scanner(System.in);
            System.out.println("1.增加员工信息" +
                    "\n2.删除员工信息"+"\n3.显示员工信息" + "\n4.输入0退出");
            int choose = input.nextInt();
            switch (choose){
                case 1:
                    System.out.println("请输入姓名：");
                    String name = input.next();
                    System.out.println("请输入工号");
                    int num = input.nextInt();
                    System.out.println("请输入年龄：");
                    int age = input.nextInt();
                    System.out.println("请输入薪水");
                    double salary = input.nextDouble();
                    Staff wok = new Staff(name,age,num,salary);
                    add(wok);
                    System.out.println("添加成功");
                    break;
                case 2:
                    System.out.println("请输入要删除的工号：");
                    num = input.nextInt();
                    remove(num);
                    break;
                case 3:
                    System.out.println("姓名：" + "  年龄" + "\t薪水" + "\t    工号");
                    List<Staff> wo = print();
                    for (int i = 0; i < wo.size(); i++) {
                        Staff wos = (Staff)wo.get(i);
                        System.out.println(wos.getName() + "    " + wos.getAge() + "\t" + wos.getSalsry() + "\t " + wos.getId());
                    }
                    break;
                case 0:
                    flag = false;
                    break;
            }
        }while(flag);
        System.out.println("成功退出,欢迎下次光临");
    }
}
